package com.mac.User;

import com.mac.pojo.User;
import com.mac.service.UserService;
import org.junit.Test;

import java.util.ArrayList;

public class test{

    UserService userService = new UserService();


    @Test
    public void ifUserExists() {
        User user = userService.ifUserExists("Sunflower");
        System.out.println(user);
    }
    @Test
    public void checkUser() {
        String username = "Sunflower";
        String password = "123456";
        final User user = userService.checkUser(username, password);
        System.out.println(user);
    }

    @Test
    public void addUser() {
        User user = new User();
        user.setUsername("Sunflower");
        user.setPassword("123456");
        user.setTelephone("15070488877");
        user.setEmail("1351982581@qq.com");

        boolean addUser = userService.addUser(user);

        System.out.println(addUser);
    }

    @Test
    public void deleteUser() {
        userService.deleteUser("Sunflower");
    }

    @Test
    public void changeUserInfo() {
        User user = new User();
        user.setUsername("Sunflower");
        user.setPassword("852456");
        user.setTelephone("15070488877");
        user.setEmail("1351982581@qq.com");

        boolean changeUserInfo = userService.changeUserInfo(user);
        System.out.println(changeUserInfo);
    }



    @Test
    public void selectAll() {
        ArrayList<User> users = userService.selectAll();

        System.out.println(users);
    }

    @Test
    public void deleteByIds() {
        final boolean b = userService.deleteByIds(new int[]{99999});
        System.out.println(b);
    }

    @Test
    public void selectByPage() {
//        ArrayList<User> users = userService.selectByPage(1, 5);

//        System.out.println(users);
    }

    @Test
    public void selectTotalCount() {
        Integer count = userService.selectTotalCount();

        System.out.println(count);
    }

    @Test
    public void selectByPageAndCondition() {
        User user = new User();
        user.setRole("admin");
//        ArrayList<User> users = userService.selectByPageAndCondition(1, 5, user);
//        System.out.println(users);
    }

    @Test
    public void selectTotalCountByCondition() {
        User user = new User();
        user.setUsername("PanJie");
        user.setRole("admin");
        Integer count = userService.selectTotalCountByCondition(user);
        System.out.println(count);
    }
}
